package GUI.almacen;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

public class AlbaranSur extends JPanel implements ActionListener{
 
	private static final long serialVersionUID = 1L;
	private Boton btn_consultar;
	private Boton btn_pendientes;
	private Boton btn_informe;
	private Albaran _albaran;
	private DialogoConsultarPedidoAlbaran _dcp;
	private DialogoPedidosPendientesAlbaran _dpp;
	
	
	public AlbaranSur(Albaran albaran){
		
		this._albaran=albaran;
		
		
        this.setBorder(new TitledBorder("Opciones"));
		this.setLayout(new GridLayout(1,3));
		
		 btn_consultar=new Boton("Consultar");
		 btn_consultar.setActionCommand("Consultar");
		 btn_consultar.addActionListener(this);
		 this.add(btn_consultar);

		 btn_pendientes=new Boton("Pendientes");
		 btn_pendientes.setActionCommand("Pendientes");
		 btn_pendientes.addActionListener(this);
		 this.add(btn_pendientes);

		 btn_informe=new Boton("Informe");
		 btn_informe.setActionCommand("Informe");
		 btn_informe.addActionListener(this);
		 this.add(btn_informe);
		
	}

	private void accion_al_consultar() {
		_dcp=new DialogoConsultarPedidoAlbaran(_albaran);
		_dcp.setVisible(true);
	}

	private void accion_al_pedir() {
		_dpp= new DialogoPedidosPendientesAlbaran(_albaran);
		_dpp.setVisible(true);
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equalsIgnoreCase("consultar")){
			accion_al_consultar();
		}else if(e.getActionCommand().equalsIgnoreCase("pendientes")){
			accion_al_pedir();
		}

	}
}
